/**
 * Created by Administrator on 2016/10/27.
 */
$(document).ready(function () {
    var banner = $(".index-banner-img img");
    var a=0;
    var b=0;
    function left_x() {
        if(a<1){
            a=4;
            banner.eq(a).stop().animate({"opacity":"1"});
            banner.eq(0).stop().animate({"opacity":"0"});
        }else {
            a--;
            banner.eq(a).stop().animate({"opacity":"1"});
            banner.eq(a+1).stop().animate({"opacity":"0"});
        }
        return a;
    }
    function right_x() {
        if(a<4){
            a++;
            banner.eq(a).animate({"opacity":"1"});
        }else{
            a=0;
            banner.eq(1).css({"opacity":"0"});
            banner.eq(2).css({"opacity":"0"});
            banner.eq(3).css({"opacity":"0"});
            banner.eq(4).stop().animate({"opacity":"0"});
            banner.eq(0).stop().animate({"opacity":"1"});
        }
        return a;
    }
    var schedule = $(".index-banner-schedule");
    function schedule_x() {
        if(b<=0){
            b=4;
        }else{
            b--;
        }
        schedule.eq(b).addClass("index-schedule-effect");
        schedule.eq(b).parent().siblings().children().removeClass("index-schedule-effect");
        return b;
    }
    function schedule_y() {
        if(b>=4){
            b=0;
        }else{
            b++;
        }
        schedule.eq(b).addClass("index-schedule-effect");
        schedule.eq(b).parent().siblings().children().removeClass("index-schedule-effect");
        return b;
    }
    var schedule_lp = setInterval(function () {schedule_y()},4000);
    var banner_lp = setInterval(function () {right_x()},4000);
    $(".index-banner").mouseenter(function () {
        clearInterval(banner_lp);
        clearInterval(schedule_lp);
    });
    $(".index-banner").mouseleave(function () {
        banner_lp = setInterval(function () {right_x()},4000);
        schedule_lp = setInterval(function () {schedule_y()},4000);
    });
    $(".index-banner-left").click(function () {
        clearInterval(banner_lp);
        clearInterval(schedule_lp);
        left_x();
        schedule_x();
    });
    $(".index-banner-right").click(function () {
        clearInterval(banner_lp);
        clearInterval(schedule_lp);
            right_x();
            schedule_y();
    });

    /*轮播图导航*/
    $(".index-banner-number ul li").click(function(){
       $(this).children().addClass("index-schedule-effect");
       $(this).siblings().children().removeClass("index-schedule-effect");
        a = b = $(this).index();
        console.log(b+"+"+a);
       banner.eq(b).animate({"opacity":"1"});
       banner.eq(b).parent().siblings().children().animate({"opacity":"0"});
       return b;
       return a;
    });


    /*最热职位和最新职位的更换效果*/
    $(".index-post-left p").click(function () {
        $(".index-post-centont-box").stop().animate({"left":"0"},1000);
        $(this).parent().removeClass("index-post-content-effect");
        $(this).parent().siblings().addClass("index-post-content-effect");
    });

    $(".index-post-right p").click(function () {
        $(".index-post-centont-box").stop().animate({"left":"-1200px"},1000);
        $(this).parent().removeClass("index-post-content-effect");
        $(this).parent().siblings().addClass("index-post-content-effect");
    });

    $(".screening-nav-one span,.screening-nav-two span,.arrangement-nav span").click(function () {
        $(this).addClass("click-span");
        $(this).siblings().removeClass("click-span");
    });


    /*职位分类页*/
    $(".screening-div strong").click(function(){
        $(this).siblings(".screening-nav-more").stop().slideToggle();
        $(this).parent().siblings("li").children(".screening-nav-more").slideUp();
    });
});




